package me.zk.practice1.s;

import java.util.LinkedList;
import java.util.Stack;

/**
 * @author zhangkai
 * @date 2023/7/13 17:11
 */
public class LS_Offer_59_2 {

    LinkedList<Integer> maxStack = null;
    LinkedList<Integer> dataStack = null;
    public LS_Offer_59_2() {
        maxStack = new LinkedList<>();
        dataStack= new LinkedList<>();
    }

    public int max_value() {
        if (maxStack.isEmpty()) {
            return -1;
        }
        return maxStack.peek();
    }

    public void push_back(int value) {
        maxStack.push(Math.max(value,maxStack.peek()));
        dataStack.push(value);
    }

    public int pop_front() {
        maxStack.pop();
        return dataStack.pop();
    }

    public static void main(String[] args) {
        LS_Offer_59_2 stack = new LS_Offer_59_2();
        stack.push_back(1);
        stack.push_back(2);
        // 2 1
        // 2 1 min
        System.out.println(stack.max_value());
        stack.pop_front();
        System.out.println(stack.max_value());

    }
}
